package com.zdkj.subway.st.controller;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zdkj.common.core.util.R;
import com.zdkj.common.log.annotation.SysLog;
import com.zdkj.subway.st.entity.SwTkTicketTestItem;
import com.zdkj.subway.st.service.SwTkTicketTestItemService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;


/**
 * 车票测试项目
 *
 * @author cui_com
 * @date 2020-09-03 20:27:52
 */
@RestController
@AllArgsConstructor
@RequestMapping("/swtktickettestitem")
@Api(value = "swtktickettestitem", tags = "车票测试项目管理")
public class SwTkTicketTestItemController {

    private final SwTkTicketTestItemService swTkTicketTestItemService;

    /**
     * 分页查询
     *
     * @param page               分页对象
     * @param swTkTicketTestItem 车票测试项目
     * @return
     */
    @ApiOperation(value = "分页查询", notes = "分页查询")
    @GetMapping("/page")
    public R getSwTkTicketTestItemPage(Page page, SwTkTicketTestItem swTkTicketTestItem) {
        return R.ok(swTkTicketTestItemService.page(page, Wrappers.query(swTkTicketTestItem)));
    }


    /**
     * 通过id查询车票测试项目
     *
     * @param id id
     * @return R
     */
    @ApiOperation(value = "通过id查询", notes = "通过id查询")
    @GetMapping("/{id}")
    public R getById(@PathVariable("id") Integer id) {
        return R.ok(swTkTicketTestItemService.getById(id));
    }

    /**
     * 新增车票测试项目
     *
     * @param swTkTicketTestItem 车票测试项目
     * @return R
     */
    @ApiOperation(value = "新增车票测试项目", notes = "新增车票测试项目")
    @SysLog("新增车票测试项目")
    @PostMapping
    @PreAuthorize("@pms.hasPermission('st_swtktickettestitem_add')")
    public R save(@RequestBody SwTkTicketTestItem swTkTicketTestItem) {
        return R.ok(swTkTicketTestItemService.save(swTkTicketTestItem));
    }

    /**
     * 修改车票测试项目
     *
     * @param swTkTicketTestItem 车票测试项目
     * @return R
     */
    @ApiOperation(value = "修改车票测试项目", notes = "修改车票测试项目")
    @SysLog("修改车票测试项目")
    @PutMapping
    @PreAuthorize("@pms.hasPermission('st_swtktickettestitem_edit')")
    public R updateById(@RequestBody SwTkTicketTestItem swTkTicketTestItem) {
        return R.ok(swTkTicketTestItemService.updateById(swTkTicketTestItem));
    }

    /**
     * 通过id删除车票测试项目
     *
     * @param id id
     * @return R
     */
    @ApiOperation(value = "通过id删除车票测试项目", notes = "通过id删除车票测试项目")
    @SysLog("通过id删除车票测试项目")
    @DeleteMapping("/{id}")
    @PreAuthorize("@pms.hasPermission('st_swtktickettestitem_del')")
    public R removeById(@PathVariable Integer id) {
        return R.ok(swTkTicketTestItemService.removeById(id));
    }

}
